#include "stdafx.h"
#include "SceneManager.h"




SceneManager::SceneManager()
{
	m_nCurrentInstanceID = 0;
}

SceneManager::~SceneManager()
{

}

IScene*
SceneManager::getScene(int nInstanceID)
{
	SceneMap::iterator it = m_dsm.find(nInstanceID);
	if (it==m_dsm.end())
	{
		return NULL;
	}
	else
	{
		return it->second;
	}
}

IScene*
SceneManager::addScene(int nStaticID, short type)
{
	IScene* pScene = createScene(nStaticID, type);

	if (pScene)
	{
		do 
		{
			++m_nCurrentInstanceID;
		} while (m_nCurrentInstanceID==0 || getScene(m_nCurrentInstanceID)!=NULL);

		pScene->setID(m_nCurrentInstanceID);

		m_dsm[m_nCurrentInstanceID] = pScene;
	}

	return pScene;
}


bool
SceneManager::rmvScene(int nInstanceID)
{
	SceneMap::iterator it = m_dsm.find(nInstanceID);
	if (it==m_dsm.end())
	{
		return false;
	}
	else
	{
		delete it->second;
		m_dsm.erase(it);
		return true;
	}
}

IScene*
SceneManager::createScene(int nStaticID, short type)
{
	return NULL;
}
